// //我的视频

import 'dart:async';
import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_ijkplayer/flutter_ijkplayer.dart';
import 'package:moonplay/common/app_common.dart';
import 'package:moonplay/widgets/common_slider.dart';
import 'package:moonplay/widgets/popup_window.dart';


class CommonVideoPage extends StatefulWidget {
  @override
  _CommonVideoPageState createState() => _CommonVideoPageState();
}

class _CommonVideoPageState extends State<CommonVideoPage> {
  var controller = IjkMediaController();
  double _progress_video = 0;   //进度条
  bool _showControl = true;    //非全屏时播放控件显示
  bool _fullShowControl = false;    //全屏时播放控件显示
  bool _isPlay = false;    //是否正在播放
  bool _isVideo = false;    //是否播放完
  bool _isClear = false;    //选择清晰度是否打开
  bool _isCover = true;    //封面显示
  bool _isDanmu = false;    //弹幕开关
  //封面url
  String _coverUrl = "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1577722263597&di=c6057442ea82e37c8875c627f61453f0&imgtype=0&src=http%3A%2F%2Fpic1.win4000.com%2Fwallpaper%2Fa%2F57aeede231cdd.jpg";
  var _currentTime = "00:00";
  var _durationTime = "00:00";
  //计时器相关参数
  Timer _timer;
  int _countdownTime = 0;

  GlobalKey _moreKey = GlobalKey();

  Orientation get orientation => MediaQuery.of(context).orientation;
  DataSource source = DataSource.network(
    "http://oss.alizyw.com:88/api/download?repository=registry.cn-hangzhou.aliyuncs.com/alizyw/www&digest=sha256:23c11945b06a2ffb6ac84b4ee9bd3b1d8422b1e2fa59f561526d38b267b01596"
  );

  //弹幕相关参数
  Timer _danmuTimer;
  int _currentTimeInMs = 0;
  // List<DataBean> _danmuDataList = List();
  // GlobalKey<BarrageViewState> _barrageKey = new GlobalKey<BarrageViewState>();

  @override
  void initState() {
    SystemChrome.setEnabledSystemUIOverlays([]);
    super.initState();
    
    _init();
    portraitUp();

    getDanmuData();
    // setDanmuTime();
  }

  @override
  void dispose() {
    SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values);
    controller.dispose();
    unlockOrientation();
    super.dispose();
    if(_timer != null) {
      _timer.cancel();
      _timer = null;
    }
    _danmuTimer?.cancel();
  }

  getDanmuData() async {
    // String data = await rootBundle.loadString("assets/test/test_data.json");
    // var result = json.decode(data);

    // if (result is List) {
    //   result.forEach((item) {
    //     DataBean bean = DataBean.fromJson(item);
    //     _danmuDataList.add(bean);
    //   });

    //   _barrageKey.currentState.updateBarrageData();
    //   setState(() {});
    // }
  }

  setDanmuTime() {
    _danmuTimer = Timer.periodic(Duration(milliseconds: 16), (t) {
      _currentTimeInMs+=16;
      setState(() {});
    });
  }

  Future _init() async {
    await controller.setDataSource(source, autoPlay: false);
    // await controller.play();
  }

  /**
   * 非全屏时计时器方法，这里将全屏和非全屏分开了
   */
  void startCountdownTimer() {
    const oneSec = const Duration(seconds: 1);
    var callback = (timer) => {
      setState(() {
        if (_countdownTime < 1) {
          _showControl = false;
          _timer.cancel();
          _timer = null;
        } else {
          _countdownTime = _countdownTime - 1; 
        } 
      }) 
    };
    _timer = Timer.periodic(oneSec, callback);
  }

  /**
   * 开始计时
   */
  void startCoundTime(type){
    //type == 1时为单击播放器，如果控制窗口开启则将之关闭，否则开启
    if(type == 1) {
      if (_timer != null) {
        //如果倒计时存在，则取消计时器，关闭控制窗口, 将_timer赋值为null
        setState(() {
          _showControl = false;
        });
        _timer.cancel();
        _timer = null;
      } else {
        //如果倒计时不存在，则开启倒计时
        setState(() {
          _countdownTime = 1;
          _showControl = true;
        });
        //开始倒计时
        startCountdownTimer();
      }
    } else {
      if (_timer != null) {
        _timer.cancel();
      }
      setState(() {
        _countdownTime = 1;
        _showControl = true;
      });
      //开始倒计时
      startCountdownTimer();
    }
  }

  /**
   * 全屏时计时器方法，需要注意一下
   */
  void startCountdownTimerFull() {
    const oneSec = const Duration(seconds: 1);
    var callback = (timer) => {
      setState(() {
        if (_countdownTime < 1) {
          //隐藏状态栏
          // SystemChrome.setEnabledSystemUIOverlays([]);
          if(_isClear) {
            Navigator.of(context).pop();
          }
          _isClear = false;
          _fullShowControl = false;
          _timer.cancel();
          _timer = null;
        } else {
          _countdownTime = _countdownTime - 1; 
        } 
      }) 
    };
    _timer = Timer.periodic(oneSec, callback);
  }

  /**
   * 全屏开始计时
   */
  void startCoundTimeFull(type){
    //type == 1时为单击播放器，如果控制窗口开启则将之关闭，否则开启
    if(type == 1) {
      if (_timer != null) {
        //如果倒计时存在，则取消计时器，关闭控制窗口, 将_timer赋值为null
        setState(() {
          _fullShowControl = false;
        });
        _timer.cancel();
        _timer = null;
        // SystemChrome.setEnabledSystemUIOverlays([]);
      } else {
        //如果倒计时不存在，则开启倒计时
        setState(() {
          _countdownTime = 1;
          _fullShowControl = true;
          // SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values);
        });
        //开始倒计时
        startCountdownTimerFull();
      }
    } else {
      if (_timer != null) {
        _timer.cancel();
      }
      setState(() {
        //设置计时器时间，设置全屏播放控制器显示，设置状态栏显示
        _countdownTime = 1;
        _fullShowControl = true;
        // SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values);
      });
      //开始倒计时
      startCountdownTimerFull();
    }
  }

  //定义播放控件显示
  Widget _buildStatusWidget(
    BuildContext context,
    IjkMediaController controller,
    IjkStatus status,
  ) {
    // print('这个状态的值是：$status');
    controller.getVideoInfo().then((val) {
      // print("有没有走到这里: ${val}");
      print("总时长: ${val.duration}秒, 播放到: ${val.currentPosition}秒, 视频宽: ${val.width}, 视频高: ${val.height}, 是否正在播放: ${val.isPlaying}");
      var _pro = (val.currentPosition/val.duration) * 100;
      setState(() {
        _currentTime = _timeFit(val.currentPosition);
        _durationTime = _timeFit(val.duration);
        _progress_video = _pro <= 100 ? _pro : 100.00;
      });
    });
    
    if(status == IjkStatus.pause){
      _isPlay = false;
    }
    if(status == IjkStatus.playing){
      _isCover = false;
      _isPlay = true;
    }
    if(status == IjkStatus.complete){
      //播放完成
      _isVideo = true;
    }
    // if (status == IjkStatus.noDatasource) {
    //   return Center(
    //     child: Text(
    //       "no data",
    //       style: TextStyle(color: Colors.white),
    //     ),
    //   );
    // }
    return Container();

    return IjkStatusWidget.buildStatusWidget(context, controller, status);
  }

  @override
  Widget build(BuildContext context) {
    if (orientation == Orientation.landscape) {
      // logger.d('如果是全屏');
      return buildLandscape();
    }
    // logger.d('否则执行这里');
    return buildNormal();
  }

  //全屏UI
  Widget buildLandscape() {
    // SystemChrome.setEnabledSystemUIOverlays([]);
    // OrientationPlugin.setEnabledSystemUIOverlays([]);
    return WillPopScope(
      child: Scaffold(
        body: Stack(
          children: <Widget>[
            Container(
              child: IjkPlayer(
                mediaController: controller,
                statusWidgetBuilder: _buildStatusWidget,
                controllerWidgetBuilder: (mediaController){
                  return GestureDetector(
                    onTap: (){
                      logger.d('全屏时点击屏幕');
                      startCoundTimeFull(1);
                    },
                    onDoubleTap: (){
                      controller.playOrPause();
                    },
                    child: Container(
                      width: double.infinity,
                      height: double.infinity,
                      color: _fullShowControl ? Color.fromARGB(100, 0, 0, 0) : Colors.transparent,
                      child: Stack(
                        children: <Widget>[
                          if(_isDanmu) Container(
                            height: 0,
                            child: Container(),
                            // child: _danmuView(),
                          ),
                          _fullShowControl ? _fullVideoUI(): Container()
                        ],
                      )
                    ),
                  );
                }
              ),
            ),
            !_fullShowControl ?Positioned(
              left: 0,
              right: 0,
              bottom: 0,
              child: _progressNotFull(),
            ) : Container()
          ],
        ),
      ),
      onWillPop: () async {
        if (orientation == Orientation.landscape) {
          portraitUp();
          return false;
        }
        return true;
      },
    );
  }

  //非全屏UI
  Widget buildNormal() {
    return SafeArea(
      child: Container(
        width: double.infinity,
        child: _videoUI(),
      ),
    );
  }

  //定义一个方法，计算播放器当前播放的进度时间
  _timeFit(time){
    var _fnMinute;
    var _fnSecond = '00';
    String _a1 = time.toStringAsFixed(0);
    // int _b1 = _a1.to
    //_b1获取当前时间是多少分钟
    int _b1 = int.parse(_a1)~/60;
    //取余，得到秒数
    int _b2 = int.parse(_a1)%60;
    if(_b1 < 10) {
      _fnMinute = '0' + _b1.toString();
    }
    if(_b2 < 10) {
      _fnSecond = '0' + _b2.toString();
    } else {
      _fnSecond = _b2.toString();
    }
    
    var _rn = _fnMinute + ':' + _fnSecond;
    return _rn;
  }

  //跳转进度
  Future _videoSeek(seekTime) async {
    await controller.seekToProgress(seekTime);
  }

  //非全屏时自定义的UI
  Widget _videoUI(){
    return IjkPlayer(
      mediaController: controller,
      //更改当前播放器状态中显示的样式（去掉中间那个播放按钮）
      statusWidgetBuilder: _buildStatusWidget,
      controllerWidgetBuilder: (mediaController){
        return GestureDetector(
          onTap: (){
            logger.d('点击屏幕');
            startCoundTime(1);
          },
          onDoubleTap: (){
            logger.d('双击屏幕');
            controller.playOrPause();
          },
          child: Container(
            width: double.infinity,
            height: double.infinity,
            color: Colors.transparent,
            child: Stack(
              children: <Widget>[
                //这里是非全屏时的弹幕
                // Container(
                //   height: 0,
                //   child: _danmuView(),
                // ),
                _showControl
                ? Positioned(
                  top: 0,
                  left: 0,
                  right: 0,
                  bottom: 0,
                  child: Container(
                    color: Color.fromARGB(100, 0, 0, 0),
                    child: Stack(
                      children: <Widget>[
                        Positioned(
                          top: 0,
                          bottom: 0,
                          left: 0,
                          right: 0,
                          child: !_isVideo ? _videoPlayOrPause() : _videoComplete()
                        ),
                        Positioned(
                          bottom: 0,
                          left: 0,
                          right: 0,
                          child: Container(
                            height: ScreenUtil().getHeightPx(80),
                            padding: EdgeInsets.fromLTRB(15, 0, 0, 0),
                            child: Row(
                              children: <Widget>[
                                Expanded(
                                  flex: 4,
                                  child: Container(
                                    alignment: Alignment.centerLeft,
                                    child: Text('${_currentTime}', style: TextStyle(color: Colors.white,fontSize: 14),),
                                  ),
                                ),
                                Expanded(
                                  flex: 22,
                                  child: Container(
                                    child: _progressView()
                                  ),
                                ),
                                Expanded(
                                  flex: 4,
                                  child: Container(
                                    alignment: Alignment.centerRight,
                                    child: Text('${_durationTime}', style: TextStyle(color: Colors.white,fontSize: 14),),
                                  ),
                                ),
                                Expanded(
                                  flex: 5,
                                  child: InkResponse(
                                    onTap: (){
                                      logger.d('点击全屏按钮');
                                      setLandScapeLeft();
                                    },
                                    highlightColor: Colors.transparent,
                                    radius: 0.0,
                                    child: Container(
                                      padding: EdgeInsets.only(right: 15),
                                      margin: EdgeInsets.only(bottom: 3),
                                      alignment: Alignment.centerRight,
                                      child: Icon(IconData(0xe660, fontFamily: Constants.IconFontFamily),color: Colors.white ,size: 18),
                                    ),
                                  )
                                ),
                              ]
                            )
                          ),
                        ),
                        Positioned(
                          top: 0,
                          right: 0,
                          child: InkResponse(
                            onTap: (){
                              logger.d('点击更多');
                            },
                            highlightColor: Colors.transparent,
                            radius: 0.0,
                            child: Container(
                              width: 50,
                              height: 45,
                              padding: EdgeInsets.only(right: 15),
                              alignment: Alignment.centerRight,
                              child: Icon(IconData(0xe73a, fontFamily: Constants.IconFontFamily),color: Colors.white ,size: 26),
                            ),
                          ),
                        )
                      ],
                    ),
                  ),
                ) : Container(),
                // _isCover ? Positioned(
                //   top: 0,
                //   left: 0,
                //   right: 0,
                //   bottom: 0,
                //   child: Image.network(_coverUrl, fit: BoxFit.cover),
                // ) : Container(),
                Positioned(
                  top: 0,
                  left: 0,
                  child: GestureDetector(
                    onTap: (){
                      logger.d('点击返回');
                      Navigator.of(context).pop();
                    },
                    child: Container(
                      width: 50,
                      height: 45,
                      padding: EdgeInsets.only(left: 10),
                      alignment: Alignment.centerLeft,
                      child: Icon(IconData(0xe632, fontFamily: Constants.IconFontFamily),color: Colors.white ,size: 24),
                    ),
                  ),
                ),
                !_showControl ? Positioned(
                  bottom: 0,
                  left: 0,
                  right: 0,
                  child: _progressNotFull(),
                ) : Container(),
              ],
            ),
          )
        );
      },
    );
  }

  //自定义播放控件里面的进度条（不是最底下的进度条）(非全屏)
  Widget _progressView(){
    return SliderTheme( //自定义风格
      data: SliderTheme.of(context).copyWith(
        activeTrackColor: Color(0xfff85959), //进度条滑块左边颜色
        inactiveTrackColor: Color.fromARGB(100, 255, 255, 255), //进度条滑块右边颜色
        trackShape: RoundSliderTrackShape(radius: 5),//进度条形状,这边自定义两头显示圆角
        thumbColor: Colors.white, //滑块颜色
        overlayColor: Color.fromARGB(100, 255, 255, 255), //滑块拖拽时外圈的颜色
        overlayShape: RoundSliderOverlayShape(//可继承SliderComponentShape自定义形状
          overlayRadius: 15, //滑块外圈大小
        ),
        thumbShape: RoundSliderThumbShape(//可继承SliderComponentShape自定义形状
          // disabledThumbRadius: 15, //禁用是滑块大小
          enabledThumbRadius: 7, //滑块大小
        ),
        trackHeight: 2 //进度条宽度
      ),
      child: Slider(
        value: _progress_video,
        min: 0.0,
        max: 100.0,
        onChanged: (val) {
          startCoundTime(2);
          _videoSeek(val/100);
        },
      ),
    );
  }

  //播放中或暂停
  Widget _videoPlayOrPause(){
    return Container(
      alignment: Alignment.center,
      child: GestureDetector(
        onTap: (){
          setState(() {
            _isPlay = !_isPlay;
          });
          controller.playOrPause();
          startCoundTime(2);
        },
        child: Container(
          width: 45,
          height: 45,
          alignment: Alignment.center,
          padding: EdgeInsets.only(left: 4),
          decoration: BoxDecoration(
            color: Color.fromARGB(100, 0, 0, 0),
            borderRadius: BorderRadius.all(Radius.circular(45)),
          ),
          child: Icon(IconData(_isPlay ? 0xe674 : 0xe78e, fontFamily: Constants.IconFontFamily),color: Colors.white ,size: 22),
        ),
      ),
    );
  }

  //播放状态(播放完成)非全屏
  Widget _videoComplete(){
    return Container(
      alignment: Alignment.center,
      child: GestureDetector(
        onTap: (){
          setState(() {
            _isPlay = !_isPlay;
          });
          logger.d('点击重播');
          // controller.playOrPause();
        },
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Container(
              width: 45,
              height: 45,
              decoration: BoxDecoration(
                color: Color.fromARGB(100, 0, 0, 0),
                borderRadius: BorderRadius.all(Radius.circular(45)),
              ),
              child: Icon(IconData(0xe782, fontFamily: Constants.IconFontFamily),color: Colors.white ,size: 22),
            ),
            SizedBox(height: 2),
            Text('重播',style: TextStyle(color: Colors.white, fontSize: 14),)
          ],
        )
      ),
    );
  }

  //播放状态(播放完成)全屏, 可以定义更多UI样式
  Widget _videoFullComplete(){
    return Container(
      alignment: Alignment.center,
      child: GestureDetector(
        onTap: (){
          setState(() {
            _isPlay = !_isPlay;
          });
          logger.d('点击重播');
          controller.playOrPause();
        },
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Container(
              width: 45,
              height: 45,
              decoration: BoxDecoration(
                color: Color.fromARGB(100, 0, 0, 0),
                borderRadius: BorderRadius.all(Radius.circular(45)),
              ),
              child: Icon(IconData(0xe782, fontFamily: Constants.IconFontFamily),color: Colors.white ,size: 22),
            ),
            SizedBox(height: 2),
            Text('重播',style: TextStyle(color: Colors.white, fontSize: 14),)
          ],
        )
      ),
    );
  }

  //全屏UI
  Widget _fullVideoUI(){
    return Stack(
      children: <Widget>[
        Positioned(
          top: 0,
          left: 0,
          right: 0,
          bottom: 0,
          child: !_isVideo ? _videoPlayOrPause() : _videoFullComplete()
        ),
        Positioned(
          top: 0,
          left: 0,
          right: 0,
          child: Container(
            child: Row(
              children: <Widget>[
                GestureDetector(
                  onTap: (){
                    if (orientation == Orientation.landscape) {
                      portraitUp();
                      return false;
                    }
                  },
                  child: Container(
                    width: 50,
                    height: 55,
                    padding: EdgeInsets.only(left: 10),
                    alignment: Alignment.centerLeft,
                    color: Colors.transparent,
                    child: Icon(IconData(0xe632, fontFamily: Constants.IconFontFamily),color: Colors.white ,size: 21),
                  ),
                ),
                Container(
                  height: 45,
                  alignment: Alignment.centerLeft,
                  child: Text('这是标题', style: TextStyle(fontSize: 15, color: Colors.white),),
                )
              ],
            ),
          ),
        ),
        Positioned(
          bottom: 0,
          left: 0,
          right: 0,
          child: Container(
            height: 40,
            child: Row(
              children: <Widget>[
                Expanded(
                  flex: 3,
                  child: Container(
                    padding: EdgeInsets.only(left: 15),
                    alignment: Alignment.centerLeft,
                    child: Text('${_currentTime}', style: TextStyle(color: Colors.white,fontSize: 14),),
                  ),
                ),
                Expanded(
                  flex: 20,
                  child: Container(
                    child: _progressView()
                  ),
                ),
                Expanded(
                  flex: 3,
                  child: Container(
                    alignment: Alignment.centerRight,
                    child: Text('${_durationTime}', style: TextStyle(color: Colors.white,fontSize: 14),),
                  ),
                ),
                Expanded(
                  flex: 2,
                  child: GestureDetector(
                    onTap: (){
                      danmuFun();
                    },
                    child: Container(
                      alignment: Alignment.center,
                      child: Icon(IconData(_isDanmu ? 0xe656 : 0xe65b, fontFamily: Constants.IconFontFamily),color: Colors.white ,size: 21),
                    ),
                  )
                ),
                Expanded(
                  flex: 3,
                  child: GestureDetector(
                    onTap: (){
                      logger.d('切换清晰度');
                      _showMoreMenu();
                    },
                    key: _moreKey,
                    child: Container(
                      alignment: Alignment.center,
                      child: Text('超清', style: TextStyle(color: Colors.white,fontSize: 15),),
                    ),
                  )
                ),
                Expanded(
                  flex: 2,
                  child: InkResponse(
                    onTap: (){
                      if (orientation == Orientation.landscape) {
                        portraitUp();
                        return false;
                      }
                    },
                    highlightColor: Colors.transparent,
                    radius: 0.0,
                    child: Container(
                      padding: EdgeInsets.only(right: 15),
                      margin: EdgeInsets.only(bottom: 3),
                      alignment: Alignment.centerRight,
                      child: Icon(IconData(0xe661, fontFamily: Constants.IconFontFamily),color: Colors.white ,size: 18),
                    ),
                  )
                ),
              ],
            ),
          ),
        ),
      ],
    );
  }

  //非全屏播放控件隐藏情况下在视频最下边显示播放进度
  Widget _progressNotFull(){
    return SliderTheme( //自定义风格
      data: SliderTheme.of(context).copyWith(
        activeTrackColor: Color(0xfff85959), //进度条滑块左边颜色
        inactiveTrackColor: Colors.transparent, //进度条滑块右边颜色
        trackShape: RoundSliderTrackShape(radius: 0),//进度条形状,这边自定义两头显示圆角
        thumbColor: Colors.yellow, //滑块颜色
        overlayColor: Colors.transparent, //滑块拖拽时外圈的颜色
        overlayShape: RoundSliderOverlayShape(//可继承SliderComponentShape自定义形状
          overlayRadius: 0, //滑块外圈大小
        ),
        thumbShape: RoundSliderThumbShape(//可继承SliderComponentShape自定义形状
          // disabledThumbRadius: 15, //禁用是滑块大小
          enabledThumbRadius: 0, //滑块大小
        ),
        inactiveTickMarkColor: Colors.black,
        showValueIndicator: ShowValueIndicator.onlyForDiscrete,//气泡显示的形式
        valueIndicatorColor: Colors.red,//气泡颜色
        valueIndicatorShape: PaddleSliderValueIndicatorShape(),//气泡形状
        valueIndicatorTextStyle: TextStyle(color: Colors.black),//气泡里值的风格
        trackHeight: 2 //进度条宽度
      ),
      child: Slider(
        value: _progress_video,
        onChanged: (v) {},
        max: 100,
        min: 0,
      ),
    );
  }

  //全屏
  setLandScapeLeft() async {
    await IjkManager.setLandScape();
    SystemChrome.setPreferredOrientations([
      DeviceOrientation.landscapeLeft,
      DeviceOrientation.landscapeLeft,
    ]);
  }

  //退出全屏
  portraitUp() async {
    await IjkManager.setPortrait();
    SystemChrome.setPreferredOrientations([
      DeviceOrientation.portraitUp,
    ]);
  }

  unlockOrientation() async {
    await IjkManager.unlockOrientation();
  }

  danmuFun(){
    if(_isDanmu) {
      _danmuTimer?.cancel();
    } else {
      setDanmuTime();
    }
    setState(() {
      _isDanmu = !_isDanmu;
    });
  }

  _showMoreMenu(){
    // if(_timer != null) {
    //   _timer.cancel();
    //   setState(() {
    //     _fullShowControl = true;
    //     _timer = null;
    //   });
    // }
    setState(() {
      _isClear = true;
    });
    startCoundTimeFull(2);
    
    final RenderBox button = _moreKey.currentContext.findRenderObject();
    final RenderBox overlay = Overlay.of(context).context.findRenderObject();
    //将y轴的高度减去view高度就得到反方向的容器
    var a =  button.localToGlobal(Offset(button.size.width + 12.0, button.size.height - 170.0), ancestor: overlay);
    var b =  button.localToGlobal(button.size.bottomLeft(Offset(0, 12)), ancestor: overlay);
    final RelativeRect position = RelativeRect.fromRect(
      Rect.fromPoints(a, b),
      Offset.zero & overlay.size,
    );
    logger.d(position);
    showPopupWindow(
      context: context,
      fullWidth: false,
      isShowBg: false,
      position: position,
      elevation: 0.0,
      bakFun: _showPopBackFun,
      child: Container(
        width: 80,
        height: 120,
        decoration: BoxDecoration(
          color: Colors.black,
          borderRadius: BorderRadius.all(Radius.circular(5.0))
        ),
        child: Column(
          children: _clearView(),
        ),
      ),
    );
  }

  List<Widget> _clearView(){
    List<Widget> _list = [];
    List<String> _textList = ["超清", "高清", "标清"];
    for (var i = 0; i < 3; i++) {
      Widget _addView = Expanded(
        flex: 1,
        child: GestureDetector(
          onTap: (){
            logger.d('选择${_textList[i]}清晰度');
          },
          child: Container(
            width: double.infinity,
            alignment: Alignment.center,
            child: Text(_textList[i], style: TextStyle(color: Colors.white, fontSize: 14)),
          ),
        ),
      );
      _list.add(_addView);
    }
    return _list;
  }

  // Widget _danmuView(){
  //   return Container(
  //     height: ScreenUtil().getHeightPx(420),
  //     color: Colors.transparent,
  //     child: BarrageView<DataBean>(
  //       key: _barrageKey,
  //       data: _danmuDataList,
  //       width: double.infinity,
  //       topPadding: 0,
  //       itemBgColor: Colors.transparent,
  //       itemHeight: 14,
  //       selfItemBgColor: Colors.transparent,
  //       textColor: Colors.red,
  //       textSize: 14.0,
  //       selfTextColor: Colors.blue,
  //       currentTimeInMs: _currentTimeInMs,
  //       startTimeInSecond: 10000,
  //       clickCallback: () {},
  //       itemClickCallback: (startX, startY, item) {},
  //     ),
  //   );
  // }

  void _showPopBackFun(){
    Navigator.of(context).pop();
    if(_timer != null) {
      _timer.cancel();
    }
    setState(() {
      _fullShowControl = false;
      _timer = null;
    });
  }
}

// class DataBean extends BarrageItemBean {
//   int commentId;
//   String content;
//   String createTime;
//   int danmuTime;
//   bool isFake;

//   factory DataBean.fromJson(Map<String, dynamic> json) => DataBean(
//       commentId: json['commentId'] as int,
//       content: json['content'] as String,
//       createTime: json['createTime'] as String,
//       danmuTime: json['danmuTime'] as int,
//       isFake: json['isFake'] as bool);

//   DataBean(
//       {this.commentId,
//       this.content,
//       this.createTime,
//       this.danmuTime,
//       this.isFake});

//   @override
//   getBarrageContent() {
//     return content;
//   }

//   @override
//   getBarrageCreateTime() {
//     return createTime;
//   }

//   @override
//   getBarrageId() {
//     return commentId;
//   }

//   @override
//   getBarrageShowTime() {
//     return danmuTime;
//   }

//   @override
//   isSelf() {
//     return isFake;
//   }
// }